package com.lecture.java8.time;

import javax.net.ssl.SNIServerName;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @program: spring-lecture
 * @description:
 * @author: luyn
 * @create: 2020-03-31 10:41
 **/
public class ServiceNameSpec {
    final List<SNIServerName> serverNames;
    public ServiceNameSpec(List<SNIServerName> serverNames) {
        this.serverNames = Collections.unmodifiableList(serverNames);
    }
    public void addServerName(SNIServerName serverName) {
        serverNames.add(serverName);
    }
    public String toString() {
        if (serverNames == null || serverNames.isEmpty())
            return "<no server name indicator specified>";
        StringBuilder builder = new StringBuilder(512);
        for (SNIServerName sn : serverNames) {
            builder.append(sn.toString());
            builder.append("\n");
        }
        return builder.toString();
    }

}
